package com.ruoyi.web.controller.car;

import java.util.List;

import com.ruoyi.system.service.IHuocheduiService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Huochedui;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 货车车队 信息操作处理
 * 
 * @author ruoyi
 * @date 2019-07-16
 */
@Controller
@RequestMapping("/system/huochedui")
public class HuocheduiController extends BaseController
{
    private String prefix = "system/huochedui";
	
	@Autowired
	private IHuocheduiService huocheduiService;
	
	@RequiresPermissions("system:huochedui:view")
	@GetMapping()
	public String huochedui()
	{
	    return prefix + "/huochedui";
	}
	
	/**
	 * 查询货车车队列表
	 */
	@RequiresPermissions("system:huochedui:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(Huochedui huochedui)
	{
		startPage();
        List<Huochedui> list = huocheduiService.selectHuocheduiList(huochedui);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出货车车队列表
	 */
	@RequiresPermissions("system:huochedui:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Huochedui huochedui)
    {
    	List<Huochedui> list = huocheduiService.selectHuocheduiList(huochedui);
        ExcelUtil<Huochedui> util = new ExcelUtil<Huochedui>(Huochedui.class);
        return util.exportExcel(list, "huochedui");
    }
	
	/**
	 * 新增货车车队
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存货车车队
	 */
	@RequiresPermissions("system:huochedui:add")
	@Log(title = "货车车队", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(Huochedui huochedui)
	{		
		return toAjax(huocheduiService.insertHuochedui(huochedui));
	}

	/**
	 * 修改货车车队
	 */
	@GetMapping("/edit/{huocheduiId}")
	public String edit(@PathVariable("huocheduiId") Integer huocheduiId, ModelMap mmap)
	{
		Huochedui huochedui = huocheduiService.selectHuocheduiById(huocheduiId);
		mmap.put("huochedui", huochedui);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存货车车队
	 */
	@RequiresPermissions("system:huochedui:edit")
	@Log(title = "货车车队", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(Huochedui huochedui)
	{		
		return toAjax(huocheduiService.updateHuochedui(huochedui));
	}
	
	/**
	 * 删除货车车队
	 */
	@RequiresPermissions("system:huochedui:remove")
	@Log(title = "货车车队", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(huocheduiService.deleteHuocheduiByIds(ids));
	}
	
}
